import 'package:flutter/material.dart';
import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart';

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(

      appBar: AppBar(

        leading: IconButton(onPressed: (){

        }, icon: CircleAvatar(
          backgroundImage: NetworkImage('https://picsum.photos/200'), // 用户头像URL
          radius: 20,
        )),
        title: Text("APP实战开发",style: TextStyle(),),
        centerTitle: true,
        actions: [
         IconButton(onPressed: (){

         }, icon: Icon(Icons.search))
        ],
      ),
      body:  Column(
        children: [
          Container(
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(12.0)
            ),
            width: 400,
            height: 150,
            margin: EdgeInsets.only(bottom: 10),
            child: Swiper(
                indicatorLayout: PageIndicatorLayout.NONE,
                autoplay: true,
                pagination: const SwiperPagination(),
                control: const SwiperControl(),
                itemBuilder: (context,index){
                  final List<String> imageUrls = [
                    'https://picsum.photos/id/10/800/400', // 风景图片
                    'https://picsum.photos/id/20/800/400', // 建筑图片
                    'https://picsum.photos/id/30/800/400', // 人物图片
                    'https://picsum.photos/id/40/800/400', // 自然图片
                  ];
                  return Container(
                    color: Colors.lightBlue,
                    child: Image.network(
                      imageUrls[index],
                      fit: BoxFit.cover,
                    ),
                  );
                },
                itemCount: 4
            ),

          ),
          Expanded(
              child: ListView.builder(
                itemCount: 10,
                  itemBuilder: (context,index){
                    return Center(

                      child: Container(
                        padding: EdgeInsets.only(top: 15,left: 15,right: 15,bottom: 0),

                        decoration: BoxDecoration(
                          border: BoxBorder.all(width: 1,color: Colors.grey)
                        ),

                        margin: EdgeInsets.only(bottom: 10),
                        width:400,
                        child: Column(
                          children: [
                            Row(
                             children: [
                               CircleAvatar(
                                 radius: 20,
                                 backgroundImage: NetworkImage(
                                     'https://cdn.pixabay.com/photo/2024/05/30/10/38/woman-8798294_1280.jpg'
                                 ),
                               ),
                               SizedBox(width: 10),
                               Text("干货",style: TextStyle(fontSize: 20)),
                               SizedBox(width: 60,),
                               Text(
                                 '2024-02-16 15:59',
                                 style: TextStyle(fontSize: 20),
                               ),
                               SizedBox(width: 15,),
                               Container(
                                 padding: EdgeInsets.only(bottom: 5),
                                   child: Text("置顶",style: TextStyle(fontSize: 18,color: Colors.blue,fontWeight: FontWeight.bold),))
                             ]
                            ),
                            SizedBox(height: 10),
                           Align(
                             child:  Text("别吐槽！轻松6步，让Android项目替换成鸿蒙递交就是滴哦骄傲i哦啊时间都i吉萨大急啊哦按时间都赛哦记得",style: TextStyle(fontSize: 15),),
                           ),
                            SizedBox(height: 2,),
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Text("干货资源",style: TextStyle(fontSize: 16,color: Colors.green,fontWeight: FontWeight.bold)),
                                IconButton(onPressed: (){

                                }, icon: Icon(Icons.star_border))
                              ],
                            )
                          ],


                        ),

                      ),
                    );
              }
              )
          )
        ],
      )

    );

  }
}
